//
//  StatusForwardCell.swift
//  TYHWeibo
//
//  Created by IOS on 15/8/6.
//  Copyright © 2015年 IOS. All rights reserved.
//

import UIKit

class StatusForwardCell: StatusTableViewCell {
    
    override var status: Status? {
        didSet {
            let name = status?.retweeted_status?.user?.name ?? ""
            let text = status?.retweeted_status?.text ?? ""
            forwardLabel.text = "@" + name + ":" + text
        }
    }
    
    
    override func setupUI() {
        super.setupUI()
        contentView.insertSubview(backButton, belowSubview: statusPictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: backButton)
        
        //设置布局
        //背景按钮
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -8, y: 8))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: statusBottomView, size: nil)
        
        //转发文字
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: 8, y: 8))
        //图片视图
        let cons = statusPictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: 8))
        pictureHeightCons = statusPictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureWidthCons = statusPictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureTopCons = statusPictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
    }
    
    //懒加载控件
    //转发原文label
    private lazy var forwardLabel: UILabel = {
        let lab = UILabel(color: UIColor.darkGrayColor(), fontSize: 14)
        lab.numberOfLines = 0
        lab.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 16
        
        return lab
    }()
    //背景按钮
    private lazy var backButton: UIButton = {
        let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        return btn
    }()

}
